package LeetCode;

public class RotateImage
{
  //pass both
  public void rotate(int[][] matrix) {
    // Start typing your Java solution below
    // DO NOT write main() function
    int n = matrix.length;
    for(int level = 0; level < n/2; level++){
      int first = level;
      int last = n-1-level;
      for(int i = first; i < last;i++){
        int tmp = matrix[first][i];
        int offset = i - first;
        matrix[first][i] = matrix[last-offset][first];
        matrix[last-offset][first]=matrix[last][last-offset];
        matrix[last][last-offset] = matrix[i][last];
        matrix[i][last] = tmp;
      }
    }
    
}
  /**
   * @param args
   */
  public static void main(String[] args)
  {
    // TODO Auto-generated method stub

  }

}
